// components/notice/index.js
//在使用的View中引入WxParse模块
var WxParse = require('../../wxParse/wxParse.js')
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
		title: {
			type: String,
			value: '暂无通知标题'
		},
		content: {
			type: String,
			value: '暂无通知内容'
		},
		url: {
			type: String,
			value: ''
		}
	},

	/**
	 * 组件的初始数据
	 */
	data: {},

	/**
	 * 组件的方法列表
	 */
	methods: {
		close() {
			this.triggerEvent('closeNotice', {}, {})
		},
		know() {
			this.triggerEvent('knowNotice', {}, {})
		},
		goto() {
			const url = this.data.url
			let links = [
				{
					pagePath: 'pages/home/index'
				},
				{
					pagePath: 'pages/buying/index'
				},
				{
					pagePath: 'pages/shop/index'
				},
				{
					pagePath: 'pages/vip/index'
				},
				{
					pagePath: 'pages/user/index'
				}
			]
			// 判断是不是tabBar 的导航
			var isNav = links.some(item => item.pagePath == url)

			if (isNav) {
				wx.switchTab({
					url: '/' + url
				})
			} else {
				wx.navigateTo({
					url: '/' + url
				})
			}
		}
	},
	attached() {
		console.log(this.data)
		var article = this.data.content
		var that = this
		WxParse.wxParse('article', 'html', article, that, 5)
	}
})
